(async ()=>{
  const mysql = require("mysql2/promise");

  // 设置连接配置
  const cfg = {
    host:'localhost',
    user:'root',
    password:'123456',
    database:''
  }

  const connection = await mysql.createConnection(cfg)

  let ret = await connection.execute(`
  create table if not exits test(
    id INT not Null auto_increment,
    message varchar(45) null,
    primary key (id))
  `)
  console.log('create', ret);
  ret = await connection.execute(`insert into test(message) values(?)`, ["abc"])
  console.log("insert", ret);

  const [rows, field] = await connection.execute(`select * from test`)
  console.log('select', JSON.stringify(rows));
})